/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jee.forum.beans;

import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import jee.forum.controller.CategoryController;
import jee.forum.entities.Category;
import org.apache.log4j.Logger;

/**
 *
 * @author Tobi
 */
@ManagedBean(name="Topic")
@RequestScoped
public class Topic {

    Logger log = Logger.getLogger(Topic.class);
    
    @EJB
    private transient CategoryController categoryCtr;
    
    String categoryName;
    Category category;



    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String category) {
        this.categoryName = category;
    }

     public Category getCategory() {
        try {
            return categoryCtr.getCategoryByName(categoryName);
        } catch (Exception e) {
            log.error("Error on getCategory maybe no page available");
            return null; //TODO sollte noch angepasst werden, sonst gibts nur ne nullpointer
        }
    } 
}
